﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace inf_1007_devoir3
{
    public class Vehicule
    {
        private int noLocation;
        private string immatriculation;
        private string noSerie;
        private string couleur;
        private int kilometrage;
        private Modele modele;
        private List<Location> locations;
        //constucteur
        public Vehicule(int _noLocation, string _immatriculation, string _noSerie, string _couleur, int _kilometrage, Modele _modele)
        {
            noLocation = _noLocation;
            immatriculation = _immatriculation;
            noSerie = _noSerie;
            couleur = _couleur;
            kilometrage = _kilometrage;
            modele = _modele;
            locations = new List<Location>();
        }
        //get/set
        public int getNoLocation()
        {
            return noLocation;
        }
        public void setNolocation(int value)
        {
            noLocation = value;
        }

        public string getImmatriculation()
        {
            return immatriculation;
        }
        public void setImmatriculation(string value)
        {
            immatriculation = value;
        }

        public string getNoSerie()
        {
            return noSerie;
        }
        public void setNoSerie(string value)
        {
            noSerie = value;
        }

        public string getCouleur()
        {
            return couleur;
        }
        public void setCouleur(string value)
        {
            couleur = value;
        }
   
        public int getKilometrage()
        {
            return kilometrage;
        }
        public void setKilometrage(int value)
        {
            kilometrage = value;
        }

        public Modele getModele()
        {
            return modele;
        }
        public void setModele(Modele value)
        {
            modele = value;
        }
        //to string
        public override string ToString()
        {
            return "#" + noLocation + " : " + modele.ToString();
        }

        public string ToStringComplet()
        {
            return "#" + noLocation + " : " + immatriculation + "\r\n" +
                modele.ToString() + "\r\n" +
                couleur;
        }
        //obtenir la disponibilité d'un véhicule
        public bool getDisponibilite()
        {
            foreach (Location loc in locations)
            {
                if (loc.getDateRetour() == null)
                {
                    return false;
                }               
            }
            
            return true;
        }
        //ajouter une location
        public void ajouterLocation(Location location)
        {
            locations.Add(location);
        }
        //supprimer la location
        public void supprimerLocation(Location location)
        {
            locations.Remove(location);
        }
        //obtenir info modèle + véhicule
        public string[] getLigneListe()
        {
            return new string[]{
                noLocation.ToString(),
                modele.getAnnee().ToString(),
                modele.getMarque(),
                modele.getModele(),
                couleur,
                modele.getTraction(),
                modele.getTransmission(),
                modele.getNbrPlaces().ToString(),
                modele.getNbrPortes().ToString()
            };
        }
    }
}
